package com.android.views.custom_view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

import com.yds.views.R;

public class CustomViewSimple extends View {
    //获取上下文
    public CustomViewSimple(Context context) {
        this(context, null);
    }

    //获取属性
    public CustomViewSimple(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    //获取样式
    public CustomViewSimple(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.CustomViewSimple);
        int backgroundColorId = attributes.getResourceId(R.styleable.CustomViewSimple_viewBgColor,R.color.red);
        setBackgroundResource(backgroundColorId);
    }
}
